package com.tesis_2.UI;

import org.json.JSONException;

import com.example.tesis_2.R;
import com.example.tesis_2.R.layout;
import com.example.tesis_2.R.menu;
import com.tesis_2.BL.BLPlatos;
import com.tesis_2.BL.BLRestaurants;
import com.tesis_2.Utils.UTLocalesCategoryAdapter;
import com.tesis_2.Utils.UTPlatosCategoryAdapter;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.GridView;

public class UIPlatos extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		try {
			BLPlatos.fillPlatos();
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		setContentView(R.layout.activity_platos);
		
		GridView grid = (GridView)findViewById(R.id.gvBase_platos);
		grid.setAdapter(new UTPlatosCategoryAdapter(this));
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_platos, menu);
		return true;
	}
	
	public boolean onOptionsItemSelected(MenuItem item) {
	    
		Intent intent; 
		
		switch (item.getItemId()) 
	    {
	        case R.id.optLocales_menu_activity_platos:
	        	intent = new Intent(this, UILocales.class);
				//intent.putExtra("nRest", position);
				startActivity(intent);
	        break;
	        
	        case R.id.optRest_menu_activity_platos:
	        	intent = new Intent(this, UIRestaurants.class);
				//intent.putExtra("nRest", position);
				startActivity(intent);
	        break;
	        
	        case R.id.optReservas_menu_activity_platos:
	        	intent = new Intent(this, UIMisReservas.class);
				//intent.putExtra("nRest", position);
				startActivity(intent);
	        break;
	        
	        default: 
	        	
	        break;
	    }
	    return false;
	} 

}
